package com.xcy.goatmilk.controller;

import com.xcy.goatmilk.config.aop.WebLog;
import com.xcy.goatmilk.pojo.Income;
import com.xcy.goatmilk.pojo.qo.IncomeQo;
import com.xcy.goatmilk.service.IncomeService;
import com.xcy.goatmilk.wrapper.BackResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author xcy
 * @Desc
 * @date 2020/7/13 16:12
 * @Version v1.0
 */
@Api(description = "收入")
@RestController
@RequestMapping("income")
public class IncomeController {


    @Autowired
    private IncomeService incomeService;

    @ApiOperation("收入查询-按天")
    @GetMapping("listByDay")
    @WebLog(description = "收入查询-按天")
    public BackResult listByDay(@ModelAttribute IncomeQo qo) {
        return BackResult.successBack(incomeService.listByDay(qo));
    }

    @ApiOperation("收入查询-按周")
    @GetMapping("listByWeek")
    @WebLog(description = "收入查询-按周")
    public BackResult listByWeek(@ModelAttribute IncomeQo qo) {
        return BackResult.successBack(incomeService.listByWeek(qo));
    }

    @ApiOperation("收入查询-按月")
    @GetMapping("listByMonth")
    @WebLog(description = "收入查询-按月")
    public BackResult listByMonth(@ModelAttribute IncomeQo qo) {
        return BackResult.successBack(incomeService.listByMonth(qo));
    }

    @ApiOperation("收入查询-按年")
    @GetMapping("listByYear")
    @WebLog(description = "收入查询-按年")
    public BackResult listByYear(@ModelAttribute IncomeQo qo) {
        return BackResult.successBack(incomeService.listByYear(qo));
    }


    @ApiOperation("新增收入信息")
    @PostMapping("insert")
    @WebLog(description = "新增收入信息")
    public BackResult insetOne(@ModelAttribute Income income) {
        //date时间类型字符串格式: 2020-07-14 01:31:47
        incomeService.add(income);
        return BackResult.successBack();
    }

    //@ApiOperation("删除收入信息")
    //@DeleteMapping("deleteOneById/{id}")
    //@WebLog(description = "删除收入信息")
    //public BackResult deleteOneById(@PathVariable Integer id) {
    //    incomeService.deleteOneById(id);
    //    return BackResult.successBack();
    //}
    //
    //@ApiOperation("修改收入信息")
    //@PutMapping("updateById/{id}")
    //@WebLog(description = "修改收入信息")
    //public BackResult updateById(@ModelAttribute AppointmentInfo appointmentInfo) {
    //    incomeService.updateById(appointmentInfo);
    //    return BackResult.successBack();
    //}

}
